package dbUserTools;

public class userCheck {
	
	private static dbControl dbCont = new dbControl();
	
	public static boolean checkUser(String userName, String password) {
		
		String sql = "select passwd from users where username = '" + userName + "';";
		String selectedPass = null;
		
		selectedPass = dbCont.querryPassByID(sql);
		
		if(password.equals(selectedPass)) {
			return true;
		}
		
		return false;
	}
	
	public static boolean isUserExist(String username, String password) {
		
		String sql = "select * from users where username = '" + username + "';";
		
		if(dbCont.userExist(sql)) {
			return true;
		} else {
			String insert = "insert into users(username, passwd) values ('" + username + "','" + password + "');";
			dbCont.insert(insert);
			return false;
		}
	}
	
}
